#ifndef CONFIG_H
#define CONFIG_H

#define CATALOG_FILE	"catalog"

#define TABLE_TYPE_FILE    0x0001
#define INDEX_TYPE_FILE    0x0002
#define CATALOG_TYPE_FILE  0x0003

#define SUCCESS		0x0000
#define DATA_NOT_FOUND 	0x0001
#define INTERNAL_ERROR	0x0002
#define INVALID_DATA	0x0004

#define TABLE_NAME_LENGTH	9
#define ATTRIB_NAME_LENGTH	4
#define FILE_NAME_LENGTH	16

#define MAX_INDEXES	2
#define MAX_NUM_ATTRIBS	8
#define	BLOCK_LENGTH	48
#define NUM_BLOCKS	3

#define NUM_TKEYS	8

#define MAX_QUERY_SIZE	128
#define MAX_TOKENS	64
#define MAX_TOKEN_SIZE	32

#define NEW_FILE	0
#define DISK_FILE	1

#define DBG()		cout<<endl<<__FILE__<<":"<<__LINE__<<">>>"<<__FUNCTION__<<"(),";fflush(stdout);

#ifdef DEBUG
#define DBGENTER	DBG();cout<<" ENTER"<<endl;
#define DBGEXIT		DBG();cout<<" EXIT"<<endl;
#define DBGPRINTN(x)	DBG();cout<<#x<<"="<<x<<endl;
#define DBGPRINTS(x)	DBG();cout<<#x<<"="<<x<<endl;
#define DBGPRINT	printf
#define DBGPRINTF	DBG();printf
#define DBGMEMPRINT	MEMPRINT
#else
#define DBGENTER	{}// this is for debug too
#define DBGEXIT		{}// this is for debug too
#define DBGPRINTN(x)	{}// this is for debug too
#define DBGPRINTS(x)	{}// this is for debug too
#define DBGPRINT	{}// This is also a debug print
#define DBGPRINTF	{} // This is also a debug print
#define DBGMEMPRINT	// MEMPRINT
#endif


// These should always print the string
#define FATAL		DBG();fflush(stdout);printf
#define PRINT		printf
#define CODEME		FATAL("??? CODE ME ???\n");

#define HEAD		printf("\n\t");printf
#define SHEAD		printf("\n\t\t");printf
#define LINE		printf("\t\t\t");printf

#define ISNULL_TYPE		0
#define ISNUMBER_TYPE		1
#define ISATTRIB_TYPE		2
#define ISTATTRIB_TYPE		3
#define ISOPERATOR_TYPE		4
#define ISAGGREGATE_TYPE	5
#define ISCONDITION_TYPE	6

#define SUM	1
#define AVG	2
#define MIN	3
#define MAX	4
#define COUNT	5

#define OP_NULL		0
#define OP_GR		1
#define OP_LS		2
#define OP_EQ		3
#define OP_GEQ		4
#define OP_LEQ		5
#define OP_AND		6

void MEMPRINT(void *buffer, int size)
{
	char *buf= (char *) buffer;
	int i=0, j=0, n=16;

	printf("\n\n");
	do
	{
		printf("\t");
		for(j=0; j<n && i<size; j++)
		{
			printf("%02d ",buf[i++]);
		}
		printf("\n");
	}while(i < size);

	printf("\n\n");
}

#define PROJECT_NAME	"DBEngine"
#define AUTHORS 	"MBM Krishna, Nisha Acharya"
#define PROJ_DESC	"DBEngine can be used as a small database engine to store records with datatypes of 4bytes only."
#define COPYRIGHT	"Everybody is free use the source code with credit to the original authors :)"
#define MAX_VERSION	2
#define MIN_VERSION	28
#define PROMPT		printf("\n%s> ", PROJECT_NAME);

void getversion()
{
	HEAD("\n********************************************************************************************************************\n");
	HEAD("DBEngine v%d.%02d\n", MAX_VERSION, MIN_VERSION);
	HEAD("-----------------\n");
	HEAD("Authors: %s", AUTHORS);
	HEAD("Description: %s", PROJ_DESC);
	HEAD("Copyright: %s", COPYRIGHT);
	HEAD("\n********************************************************************************************************************\n");

}

#endif
